<?php

require_once WP_PLUGIN_DIR . '/diapucp-events/defines.php' ;
require_once DPEM_SMB_PATH . '/smb_basefield.php' ;

class smartmeta_text extends smb_basefieldbox {
    
    public function  __construct($fields) {
        $this->set_fields($fields);
        $this->set_inputid( $fields['id'] . '_text_field' );
        //$this->set_js_class('regular-text');
    }

    public static function build_me( $fields, &$new_field_object ){
        $new_field_object = new smartmeta_text($fields);
    }

    public function show(){
        $value = $this->fetch_value();
        ?>
            <td>
                <label for="<?php echo $this->inputid; ?>"><?php echo $this->fields['name'] ?></label>
            </td>
            <td>
                <?php $this->add_required_label(); ?>
                <input
                    id="<?php echo $this->inputid; ?>"
                    name="<?php echo $this->inputid; ?>"
                    class="regular-text"
                    value="<?php echo esc_html($value); ?>"
                    type="text"
                />
            </td>
        <?php
        $this->add_description();
    }

    public function save( $post_id ){
        $data = $_POST[ $this->inputid ];
        if ( empty( $data ) and isset($this->fields['default'] ) ){ $data = $this->fields['default']; }
        $data = wp_strip_all_tags($data);
        smb_basefieldbox::set($this->fields['id'], $data);
    }

} //End of the Class

?>

